/**
 * Created by lz on 2017/6/21.
 */

import Axios from 'axios';
// import fetch from 'node-fetch';
import queryString from 'query-string';

let url_prefix = 'http://book-api.lzuntalented.cn/index.php';
// let url_prefix = 'http://mock-api.lzuntalented.cn';
export default {
    get(url,params){
        params = params || {};
        url = url_prefix + url;
        return Axios.get(url,{
            params:params
        });
    },

    post(url,params){
        let cookie = Cookies.get();

        url = url_prefix + url;
        // return Axios.post(url,params)
        return Axios({
            method: 'post',
            url: url,
            data: queryString.stringify(params),
            onDownloadProgress: null,
            onUploadProgress : null,
            withCredentials: true,
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
                // 'lzcookie': queryString.stringify(cookie)
            }
        });
    }
};